Defines a subroutine that can be used as an expression to determine a return type.
処理結果を戻り値として返すサブルーチンを定義します。
see Parameter
パラメータを参照
Syntax
構文
Function Name[(VarName1 [As Type][, VarName2 [As Type][,...]]]) [As Type]
Function Name[(VarName1 [As Type][, VarName2 [As Type][,...]]])[As Type]
statement block
ステートメントブロック
[Exit Function]
[Exit Function]
statement block
ステートメントブロック
End Function
End Function
Parameter
パラメータ
Name: Name of the subroutine to contain the value returned by the function.
Name: 関数が返す値を格納しておくサブルーチン名。
VarName: Parameter to be passed to the subroutine.
VarName: サブルーチンに渡すパラメータ。
Type: Type-declaration keyword.
Type: 型宣言用のキーワード。
Sub ExampleExit
Sub ExampleExit
Dim sReturn As String
Dim sReturn As String
Dim sListArray(10) as String
Dim sListArray(10) as String
Dim siStep as Single
Dim siStep as Single
For siStep = 0 to 10 REM Fill array with test data
For siStep = 0 to 10 REM 配列にテスト用データを代入
sListArray(siStep) = chr$(siStep + 65)
sListArray(siStep) = chr$(siStep + 65)
msgbox sListArray(siStep)
msgbox sListArray(siStep)
next siStep
Next siStep
sReturn = LinSearch(sListArray(), "B")
sReturn = LinSearch(sListArray(), "B")
Print sReturn
Print sReturn
end sub
end sub
Function LinSearch( sList(), sItem As String ) as integer
Function LinSearch( sList(), sItem As String ) as integer
dim iCount as Integer
dim iCount as Integer
REM Linsearch searches a TextArray:sList() for a TextEntry:
REM LinSearch はテキスト配列 sList( ) 内に指定文字列を検索
REM Return value is the index of the entry or 0 (Null)
REM 戻り値は、該当するインデックス値ないしゼロ (Null)
for iCount=1 to Ubound( sList() )
for iCount=1 to Ubound( sList() )
if sList( iCount ) = sItem then
if sList( iCount ) = sItem then
exit for REM sItem found
exit for REM 検索で sItem がヒット
end if
end if
next iCount
Next iCount
if iCount = Ubound( sList() ) then iCount = 0
if iCount = Ubound( sList() ) then iCount = 0
LinSearch = iCount
LinSearch = iCount
end function
end function